home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / compile_font.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-27  |  2.0 KB  |  72 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: compile_font.c,v 1.3 89/09/27 09:14:11 sau Exp $
  9.     $Source: /m1/mgr.new/src/RCS/compile_font.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /m1/mgr.new/src/RCS/compile_font.c,v $$Revision: 1.3 $";
  12.  
  13.  
  14. /* font routines */
  15.  
  16. #include <stdio.h>
  17. #include "bitmap.h"        /* needed by font.h */
  18. #include "font.h"
  19.  
  20. /**************************************************************************
  21.  *
  22.  *    compile a font file
  23.  */
  24.  
  25. main(argc,argv)
  26. int argc;
  27. char **argv;
  28.    {
  29.    struct font_header head;
  30.    int sum=0;        /* # bytes of font data read so far */
  31.    int size;        /* # bytes of font data */
  32.    int c;            /* current font char */
  33.  
  34.    if (fread(&head,HEADER_SIZE,1,stdin) != 1) {
  35.         fprintf(stderr,"%s: sorry, Can't read font header\n",*argv);
  36.       exit(1);
  37.       }
  38.  
  39.    if (head.type == FONT_X) {
  40.         fprintf(stderr,"%s: Sorry, Obsolete font format\n",*argv);
  41.         exit(2);
  42.         }
  43.  
  44.    else if (head.type != FONT_A) {
  45.         fprintf(stderr,"%s: sorry, Input is not a font\n",*argv);
  46.       exit(3);
  47.       }
  48.                                
  49.    printf("/* static font file */\n\n");
  50.  
  51.    printf("struct font_header %s_head = {\n",argv[1]);
  52.    printf("\t(char) %d, (char) %d, (char) %d,\n",
  53.           head.type, head.wide, head.high);
  54.    printf("\t(char) %d, (char) %d, (char) %d\n",
  55.           head.baseline, head.count, head.start);
  56.    printf("\t};\n\n");
  57.  
  58.    printf("char %s_image[] = {\n\t",argv[1]);
  59.  
  60.     size = ((head.wide*head.count)+31)&~31; /* fonts always 32 bit padded */
  61.  
  62.    while(sum++<size) {
  63.       c = getchar();
  64.       printf("0x%02x,%s",c,sum%12?"":"\n\t");
  65.       }
  66.    printf("\n\t};\n\n");
  67.    printf("bit_static(%s,%d,%d,%s_image,1);\n",
  68.            argv[1],size,head.high,argv[1]);
  69.  
  70.    exit(0);
  71.    }
  72.